package org.mikeliu.exp6.homework2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;

class Infomation implements Comparable<Infomation>
{
	private String nameString;
	private Integer count=1;
	public Infomation(String nameString)
	{
		this.nameString=nameString;
	}
	public String getNameString() 
	{
		return nameString;
	}
	public void setNameString(String nameString) 
	{
		this.nameString = nameString;
	}
	public Integer getCount()
	{
		return count;
	}
	public Infomation incCount()
	{
		this.count++;
		return this;
	}
	@Override
	public int hashCode() 
	{
		return Objects.hash(nameString);
	}
	@Override
	public boolean equals(Object obj) 
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Infomation other = (Infomation) obj;
		return Objects.equals(nameString, other.nameString);
	}
	@Override
	public int compareTo(Infomation o) {
		if(this.count>o.count)
		{
			return -1;
		}
		else if(this.count<o.count) 
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
}

public class Main 
{
	public static void main(String[] args) 
	{
		List<Infomation> list=new ArrayList<>();
		Scanner scanner=new Scanner(System.in);
		while(scanner.hasNext())
		{
			String typeString=scanner.next();
			Infomation infomation=new Infomation(typeString);
			int index=list.indexOf(infomation);
			if(index==-1)
			{
				list.add(infomation);
			}
			else 
			{
				list.set(index, list.get(index).incCount());
			}
		}
		Collections.sort( list);
		for(Infomation i: list)
		{
			System.out.println(i.getNameString()+":"+i.getCount());
		}
		scanner.close();
	}
}
